<?php
  /*
  $Id: domains.php,v 2.0 2004/11/02$
  Released under the GNU General Public License
  Rewritten, Modified And added Whois By Sudhakar Bellamkonda
*/

// -- webMS Modification --
  // Ensure a valid runtime environment or die
  if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );

  // -- webMS Modification --
  // Check if osCommerce environment is already loaded
  if (defined( '_OSCOMMERCE_LOADED' )) {
    if (!DB_SHARED) {
      // Reconnect to osCommerce Database
      tep_db_connect() or die('Unable to connect to database server!');
    }
    // Load osCommerce Globals for Boxes
    global $category_links, $languages_id, $catID, $catID_array, $current_category_id;
    global $request_type, $lng, $cart, $currencies, $language, $navigation, $breadcrumb;
  } else {
    // Load osCommerce Environment for the First Time
    require('components/'.$option.'/includes/application_top.php');
  }
$type = $_POST['type']; 
$domain = $_POST['domain'];
$action = $_POST['action'];

switch ($action)
{
	case 'default':
    	   tep_redirect(FILENAME_DEFAULT);
		   break;
	case '':
	       tep_redirect(FILENAME_DEFAULT);
			break;
	case 'details':
			echo "<pre>";
			echo "use whois in your sys man!";
			echo "</pre>";
			echo "<p align=center><a href=javascript:window.close()><font face=$fontface size=$fontsize color=$stdcolor><b>CLOSE</b></font></a>";
			break;
	case 'checkdom': 
		$extld = array('.com', '.net', '.biz', '.co.uk', '.org.uk', '.info', '.uk.com', '.eu.com', '.org');
		switch($type)
		{
		case 'All':
			foreach ($extld as $tld)
				{
			    	$domname = $domain . $tld; 
					$result = 0;
					$avail = 1;
					$result = checkdnsrr($domname,'NS');
        			exec('domaincheck ' . $domname, $result1, $retval);
		        	if ($result && $result1[0]) $avail = 0;
			        tep_db_query("insert into  ".TABLE_DOMAINS ." (domain, avail, date) values ('" . $domname . "', " . $avail . ", now())");
					$tdid = tep_db_insert_id();					
				}
		break;
		case 'TLD':
//			echo 'Error Please select the TLD.<br> The Domain Extention like .co.uk or .com.';
			tep_redirect('index.php?option=com_oscommerce&osMod=register_names&action=err');
			break;
		default :
			$domname = $domain . $type;
		    $result = 0;
			$avail = 1;
			$result = checkdnsrr($domname,'NS');
			exec('domaincheck ' . $domname, $result1, $retval);
			if ($result && $result1[0]) $avail = 0;
			tep_db_query("insert into  ".TABLE_DOMAINS ." (domain, avail, date) values ('" . $domname . "', " . $avail . ", now())");
			$tdid = tep_db_insert_id();
			tep_redirect('index.php?option=com_oscommerce&osMod=register_names&action=newcount&tdid=' . $tdid );
		} // end of switch(type)		
} // end of case checkdom

?>